Skip to content

Add Py_GenericAlias#45

Closed
elprans wants to merge 1 commit into
python:mainfrom
elprans:Py_GenericAlias
Closed

Add Py_GenericAlias#45
elprans wants to merge 1 commit into
python:mainfrom
elprans:Py_GenericAlias

Conversation

@elprans

@elprans elprans commented Sep 13, 2022

Copy link
Copy Markdown

Useful for extensions implementing generic container types, like
immutables (see MagicStack/immutables#89).

Co-Authored-By: ToBeReplaced ToBeReplaced@gmail.com

Useful for extensions implementing generic container types, like
`immutables` (see MagicStack/immutables#89).

Co-Authored-By: ToBeReplaced <ToBeReplaced@gmail.com>

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this implementation fits well with pythoncapi-compat. Usually, I only provided a fallback implementation when they was a way to implement a feature on old Python. For example, PyFrame_GetBack(frame) really returns the previous frame. And PyThreadState_EnterTracing() and PyThreadState_LeaveTracing() really work as the function works on Python 3.11.

Here, it's not a type alias, it just returns the same input type, unmodified, and the second argument is just ignored. I don't see the value of adding this function to pythoncapi-compat. Why not puting an #ifdef in immutables to have a different code path on Python 3.8 and older?

In shorter, I prefer that the developer of a C extension thinks how they have to deal with Python 3.8 and older.

Sorry, I didn't put any guidelines on what belongs or not to pythoncapi-compat.

@elprans

elprans commented Sep 14, 2022

Copy link
Copy Markdown
Author

I'm not sure if this implementation fits well with pythoncapi-compat

Yeah, that makes sense, thanks for confirming. Easy to handle in the extension directly.

@elprans elprans closed this Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants